<template>
	<view class="layout">
		<uni-header :title="'修改笔记'"></uni-header>
		<view class="content">
			<view class="evaluate">
				<view class="evaluate-list">
					<text class="title-text">笔记名称</text>
					<u-input v-model="editData.note_name" type="text" placeholder="请输入笔记名称" input-align="right"
						border="false" />
				</view>
				<!--<view class="evaluate-list">
                    <text class="title-text">笔记类型</text>
                    <u-input v-model="addNote.activity_id" type="text" placeholder="请输入授课类型" input-align="right" border="false" />
                </view>-->
				<view class="evaluate-list">
					<text class="title-text">笔记内容</text>
				</view>
				<view class="evaluate-list">
					<uni-easyinput type="textarea" v-model="editData.comment" placeholder="请输入笔记内容" />
				</view>
			</view>
			<u-button type="primary" @click="editSave">保存</u-button>
		</view>
	</view>
</template>

<script>
	import {
		editNote,
		noteDetails
	} from '@/api/note'
	export default {
		data() {
			return {
				editNote: {
					id: "",
					type: "",
					deviceId: this.$store.state.user.deviceId
				},
				editData: {}
			}
		},
		onLoad(option) {
			this.editNote.id = option.id;
			this.editNote.type = option.type;
		},
		created() {
			noteDetails(this.editNote).then(res => {
				this.editData = res.record;
			})
		},
		methods: {
			editSave() {
				let params = {
					id: this.editNote.id,
					type: this.editNote.type,
					deviceId: this.editNote.deviceId,
					note_name: this.editData.note_name,
					comment: this.editData.comment,
				}
				editNote(params).then(res => {
					if (res.status == 0) {
						uni.$u.toast('修改成功');
						setTimeout(() => {
							this.$tab.reLaunch('/pages/mine/note/note')
						}, 2000);
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #f5f6f7;

		.content {
			.evaluate {
				background: #fff;
				margin-bottom: 15px;

				.evaluate-list {
					display: flex;
					justify-content: space-between;
					align-items: center;
					border-bottom: 1px solid #ddd;
					padding: 10px 15px;

					.left-title {
						width: 20vw;
					}

					.right {
						width: 80vw;
						text-align: right;
					}
				}
			}
		}
	}
</style>